<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
      let arr = [1,9,2,5,3,8,1];
      function B(data){
          if(data.length<=1){
              return data
          }
        var index = Math.floor(data.length/2);
        var sum = data.splice(index,1)[0];
        var left = [];
        let right = [];
        for(var i=0;i<data.length;i++){
            if(data[i]<sum){
               left.push(data[i])
            }else{
                right.push(data[i])
            }
        }
        return B(left).concat([sum],B(right))
      }
      let result = B(arr);
      console.log(result)
    //   new Promise(resolve => {
    //     console.log(1);
    //     resolve(3);
    //     Promise.resolve().then(()=> console.log(4))
    // }).then(num => {
    //     console.log(num);
    //     setTimeout(()=>{console.log(6)},0);
    // });

    // console.log(2);



















    </script>
</body>
</html>